2018-08-05

systemd on the Pocket Beagle

systemd...

The newish init system for Linux. Although it has been around since 2010 it has been slow to gain popularity. Currently the major Linux distributions are using it.

To see all of the active units running on your system, type the below into a terminal.

sudo systemctl

This has the units grouped by type such as service or target. To show only services type.

sudo systemctl list-units --type=service

To show all installed unit files use

sudo systemctl list-unit-files

To see the details of a service such as 'ssh' type.

sudo systemctl status ssh.service

With all of these commands you may need to press the 'enter' key to scroll and use 'CTRL + c' to return to the command prompt.

Now to turn the blink.py program into a service. From the section Blinky !!!

I have the file in /home/debian/progs. Make the file executable by running the below command.

sudo chmod +x /home/debian/progs/blink.py

To create the service command file type.

sudo vim /lib/systemd/system/blink.service

And enter the below.

[Unit]
Description=Blink Service

[Service]
ExecStart=/home/debian/progs/blink.py
StandardOutput=null

[Install]
WantedBy=multi-user.target
Alias=blink.service

To enable the service so it will run automatically after the system boots.

sudo systemctl enable blink.service

To start the service without rebooting.

sudo systemctl start blink.service

To stop the service.

sudo systemctl stop blink.service

In the event you change 'blink.py' and want to run the changes.

sudo systemctl restart blink.service

To disable the service so it will not start after a reboot.

sudo systemctl disable blink.service